using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper
{
    public class TokenShopSubjectMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public TokenShopSubjectMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<TokenShopSubject, token_shop_subject_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.title, src => src.MapFrom(c => c.Title))
                .ForMember(dest => dest.img_url, src => src.MapFrom(c => c.ImgUrl))
                .ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
                .ForMember(dest => dest.topic_link, src => src.MapFrom(c => c.TopicLink))
                .ForMember(dest => dest.pageviews_num, src => src.MapFrom(c => c.PageviewsNum))
                .ForMember(dest => dest.product_num, src => src.MapFrom(c => c.ProductNum))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime));

            _cfg.CreateMap<token_shop_subject_dto, TokenShopSubject>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Title, src => src.MapFrom(c => c.title))
                .ForMember(dest => dest.ImgUrl, src => src.MapFrom(c => c.img_url))
                .ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort))
                .ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
                .ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
                .ForMember(dest => dest.TopicLink, src => src.MapFrom(c => c.topic_link))
                .ForMember(dest => dest.PageviewsNum, src => src.MapFrom(c => c.pageviews_num))
                .ForMember(dest => dest.ProductNum, src => src.MapFrom(c => c.product_num))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time));


        }
    }
}
